import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import User from '../views/user/user.vue'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/detail/:id',
    name: 'detail',
    component: () =>
      import ('../views/detail.vue')
  },
  {
    path: '/course',
    name: 'course',
    component: () =>
      import ('../views/course.vue')
  },
  {
    path: '/user',
    name: 'user',
    component: User,
    redirect: '/balance',
    meta: {
      requireAuth: true
    },
    children: [{
        path: '/balance',
        name: 'balance',
        meta: {
          requireAuth: true
        },
        component: () =>
          import ('../views/user/balance.vue')
      },
      {
        path: '/vip',
        name: 'vip',
        meta: {
          requireAuth: true
        },
        component: () =>
          import ('../views/user/vip.vue')
      },
      {
        path: '/order',
        name: 'order',
        meta: {
          requireAuth: true
        },
        component: () =>
          import ('../views/user/order.vue')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
